package com.xbongbong.paas.service.log.crm.operation;

import com.xbongbong.paas.domain.entity.PaasFormEntity;
import com.xbongbong.paas.help.ProFormHelp;
import com.xbongbong.paas.toolbox.exception.XbbException;
import lombok.extern.slf4j.Slf4j;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * @author: yingjianfeng
 * @date: 2022/4/13 16:38
 * @description: crm和进销存操作日志公共抽象接口
 */
@Slf4j
public abstract class AbstractOperationLogHandle implements CrmOperationLogHandle {
    @Resource
    private ProFormHelp proFormHelp;

    public String getPaasFormName(String corpid,Long formId, Integer businessType) throws XbbException {
        if(Objects.isNull(corpid)||Objects.isNull(formId)||Objects.isNull(businessType)){
            return "";
        }
        PaasFormEntity paasFormEntity = null;
        try {
            paasFormEntity = proFormHelp.getPaasForm(formId, businessType, corpid);
        }catch (XbbException e){
            log.error("com.xbongbong.paas.service.log.crm.operation.AbstractOperationLogHandle.getPaasFormName: 获取不到表单实体，默认给空字符串");
            return "";
        }
        return paasFormEntity.getName();
    }


}
